
(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('react'), require('react-dom')) :
    typeof define === 'function' && define.amd ? define(['react', 'react-dom'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React, global.ReactDOM));
}(this, (function (React, ReactDOM) { 'use strict';

    function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

    var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
    var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */

    var __assign = function() {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };

    function __spreadArray(to, from) {
        for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
            to[j] = from[i];
        return to;
    }

    var useIOSActive=function(){React__default['default'].useEffect((function(){document.body.addEventListener("touchstart",(function(){}));}),[]);};

    var useParamFnFreeze=function(r){var u=React__default['default'].useRef(r);return React__default['default'].useMemo((function(){u.current=r;}),[r]),u};

    var e=React__default['default'];var usePassiveSupported=function(){var n=e.useCallback((function(){}),[]);return e.useEffect((function(){return function(){"undefined"!=typeof window&&window.removeEventListener("click",n);}}),[n]),e.useMemo((function(){var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0;}});return "undefined"!=typeof window&&window.addEventListener("click",n,t),e}),[n])};

    function createCommonjsModule(fn, basedir, module) {
    	return module = {
    	  path: basedir,
    	  exports: {},
    	  require: function (path, base) {
          return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
        }
    	}, fn(module, module.exports), module.exports;
    }

    function commonjsRequire () {
    	throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
    }

    var slideTo = createCommonjsModule(function (module, exports) {
    function e(){return "undefined"!=typeof window}function n(e,n,t,o){var i=t-n;return (e/=o/2)<1?i/2*e*e*e+n:i/2*((e-=2)*e*e+2)+n}Object.defineProperty(exports,"__esModule",{value:!0}),exports.easeInOutCubic=n,exports.slideTo=function(t){var o=t.startPos,i=t.endPos,r=t.movingTime,u=void 0===r?300:r,a=t.chunkCallback,s=t.completeCallback,c=!1,d=null;return !c&&e()&&window.requestAnimationFrame((function t(r){d||(d=r);var l=r-d,f=n(l>u?u:l,o,i,u);c||(l<u?(a&&a(f),e()&&window.requestAnimationFrame(t)):(a&&a(i),s&&s(i)));})),function(){c=!0;}};
    });

    var utils = createCommonjsModule(function (module, exports) {
    function e(e){return e*(180/Math.PI)}function t(){return "undefined"!=typeof window}Object.defineProperty(exports,"__esModule",{value:!0}),exports.exclude=function(e,t){var n=Object.create(null);for(var r in e)("string"==typeof t&&r!==t||-1===t.indexOf(r))&&(n[r]=e[r]);return n},exports.getBrowserVersion=function(){if(t()){var e=window.navigator.userAgent,n=e.indexOf("MSIE")>-1,r=/rv:(\d+\.\d+)/g.exec(e);if(n||r&&"11.0"===r[1])return "IE"}return null},exports.getClientPos=function(e){return e instanceof MouseEvent?{clientX:e.clientX,clientY:e.clientY}:{clientX:e.targetTouches[e.targetTouches.length-1].clientX,clientY:e.targetTouches[e.targetTouches.length-1].clientY}},exports.getEventId=function(e){return e instanceof MouseEvent?-1:e.targetTouches[e.targetTouches.length-1].identifier},exports.getFractionalPart=function(e,t){var n=e.toString();return n.indexOf(".")>-1&&void 0!==(n=n.split(".")[1])?void 0===t?n:n.slice(0,t):""},exports.haveToWindow=t,exports.inclinedAngle=function(t,n){var r=n.x-t.x,i=n.y-t.y;if(r>0&&0===i)return 0;if(0===r&&i>0)return 90;if(r<0&&0===i)return 180;if(0===r&&i<0)return 270;var o=e(Math.atan(i/r));return r<0&&i<0||r<0&&i>0?o+180:r>0&&i<0?o+360:o},exports.isPC=function(){if(t()){for(var e=window.navigator.userAgent,n=["Android","iPhone","SymbiontOS","Windows Phone","iPad","iPod"],r=!0,i=0;i<n.length;i+=1)if(e.indexOf(n[i])>-1){r=!1;break}return r}return !1},exports.preventDefault=function(e){return !("boolean"==typeof e.cancelable&&!e.cancelable)&&(e.preventDefault(),!0)},exports.r2a=e,exports.throwError=function(e){throw e},exports.withinRange=function(e,t,n){return t>n?e:e>n?n:e<t?t:e};
    });

    var classnames = createCommonjsModule(function (module) {
    /*!
      Copyright (c) 2017 Jed Watson.
      Licensed under the MIT License (MIT), see
      http://jedwatson.github.io/classnames
    */
    /* global define */

    (function () {

    	var hasOwn = {}.hasOwnProperty;

    	function classNames () {
    		var classes = [];

    		for (var i = 0; i < arguments.length; i++) {
    			var arg = arguments[i];
    			if (!arg) continue;

    			var argType = typeof arg;

    			if (argType === 'string' || argType === 'number') {
    				classes.push(arg);
    			} else if (Array.isArray(arg) && arg.length) {
    				var inner = classNames.apply(null, arg);
    				if (inner) {
    					classes.push(inner);
    				}
    			} else if (argType === 'object') {
    				for (var key in arg) {
    					if (hasOwn.call(arg, key) && arg[key]) {
    						classes.push(key);
    					}
    				}
    			}
    		}

    		return classes.join(' ');
    	}

    	if (module.exports) {
    		classNames.default = classNames;
    		module.exports = classNames;
    	} else {
    		window.classNames = classNames;
    	}
    }());
    });

    var svgAttr = {
        className: 'easy-icon-svg',
        viewBox: '0 0 400 400',
        width: '1em',
        height: '1em'
    };

    // 成功
    function Success(props) {
        var _a = props.fontSize, fontSize = _a === void 0 ? 30 : _a, _b = props.color, color = _b === void 0 ? '#1aad19' : _b, _c = props.animation, animation = _c === void 0 ? false : _c;
        var allowAnimation = React.useMemo(function () { return utils.getBrowserVersion() !== 'IE' && animation; }, [animation]);
        var r = React.useMemo(function () { return 170; }, []); // 半径
        var p = React.useMemo(function () { return 2 * Math.PI * r; }, [r]); // 周长
        var circleOffset = React.useMemo(function () { return allowAnimation ? p : 0; }, [allowAnimation, p]);
        var pathOffset = React.useMemo(function () { return allowAnimation ? 235 : 0; }, [allowAnimation]);
        return (React__default['default'].createElement("svg", __assign({}, svgAttr, { fontSize: fontSize, color: color }),
            React__default['default'].createElement("circle", { className: classnames('easy-icon-circle-rotateX180', { 'easy-icon-animation': allowAnimation }), cx: "200", cy: "200", r: r, stroke: "currentColor", fill: "transparent", strokeWidth: "20", strokeDashoffset: circleOffset, strokeDasharray: p }),
            React__default['default'].createElement("path", { className: classnames({ 'easy-icon-animation': allowAnimation }, 'easy-icon-animation-duration040', 'easy-icon-animation-delay010'), stroke: "currentColor", fill: "transparent", strokeWidth: "20", strokeDashoffset: pathOffset, strokeDasharray: "235", d: "M 130 230 L 190 270 L 280 140", strokeLinecap: "round", strokeLinejoin: "round" })));
    }

    // 错误
    function Error$1(props) {
        var _a = props.fontSize, fontSize = _a === void 0 ? 30 : _a, _b = props.color, color = _b === void 0 ? '#ffffff' : _b, _c = props.bgColor, bgColor = _c === void 0 ? '#e74845' : _c, _d = props.animation, animation = _d === void 0 ? false : _d;
        var allowAnimation = React.useMemo(function () { return utils.getBrowserVersion() !== 'IE' && animation; }, [animation]);
        var lineOffset = React.useMemo(function () { return allowAnimation ? 250 : 0; }, [allowAnimation]);
        return (React__default['default'].createElement("svg", __assign({}, svgAttr, { fontSize: fontSize, color: color }),
            React__default['default'].createElement("circle", { fill: bgColor, cx: "200", cy: "200", r: "170" }),
            React__default['default'].createElement("line", { className: classnames({ 'easy-icon-animation': allowAnimation }), strokeLinecap: "round", stroke: "currentColor", strokeWidth: "20", x1: "140", y1: "140", x2: "260", y2: "260", strokeDashoffset: lineOffset, strokeDasharray: "250" }),
            React__default['default'].createElement("line", { className: classnames({ 'easy-icon-animation': allowAnimation }, 'easy-icon-animation-delay015'), strokeLinecap: "round", stroke: "currentColor", strokeWidth: "20", x1: "260", y1: "140", x2: "140", y2: "260", strokeDashoffset: lineOffset, strokeDasharray: "250" })));
    }

    var dom = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports,"__esModule",{value:!0}),exports.classListAdd=function(s,t){if(s.classList&&s.classList.add)s.classList.add(t);else {var e=s.getAttribute("class");if(e){var n=e.split(/\s/g);-1===n.indexOf(t)&&(n.push(t),s.setAttribute("class",n.join(" ")));}}},exports.findParentNode=function(s,t){var e=null;if(s)for(;s&&s.classList&&s.classList.contains;)s.classList.contains(t)?(e=s,s=null):s=s.parentNode?s.parentNode:null;return e},exports.getStyleValue=function(s){return s?s.getBoundingClientRect():null};
    });

    function Down(props, ref) {
        var status = props.status, offset = props.offset, outOffsetRate = props.outOffsetRate;
        var downRef = React.useRef(null); // 下拉刷新盒子容器
        var dragInnerRef = React.useRef(null); // 下拉SVG
        var dragCircleRef = React.useRef(null); // 下拉的圆
        var perimeter = React.useMemo(function () { return Math.PI * 300; }, []); // 下拉圆的周长
        var fontSize = React.useMemo(function () { return 20; }, []); // 下拉刷新文字的高度
        var beginShowHeight = React.useMemo(function () { return offset - fontSize; }, [offset, fontSize]); // 开始显示圆的下拉高度
        var showMaxPerimeter = React.useMemo(function () { return perimeter * 0.8; }, [perimeter]); // 显示的最大圆周长
        var rotate = React.useRef(-90); // 旋转角度 等同于css默认已经旋转了的角度
        var getRefreshDOM = React.useMemo(function () {
            if ([1, 2, 3, 4, 6].indexOf(status) > -1) {
                return (React__default['default'].createElement(React.Fragment, { key: "refresh" },
                    React__default['default'].createElement("svg", { ref: dragInnerRef, className: "easy-scroll-down-inner-refresh", viewBox: "0 0 400 400", width: "1em", height: "1em" },
                        React__default['default'].createElement("circle", { ref: dragCircleRef, cx: "200", cy: "200", r: "150", strokeWidth: "30", stroke: "currentColor", strokeOpacity: "0", fill: "transparent", strokeDashoffset: perimeter, strokeDasharray: perimeter + "," + perimeter })),
                    React__default['default'].createElement("span", { className: "easy-scroll-down-inner-text" }, (function () {
                        if (status === 1) {
                            return '下拉刷新';
                        }
                        if (status === 2) {
                            return '释放刷新';
                        }
                        if (status === 3) {
                            return '马上刷新';
                        }
                        if (status === 4) {
                            return '正在刷新';
                        }
                        if (status === 6) {
                            return '我回去咯';
                        }
                    })())));
            }
            if (status === 5) {
                return (React__default['default'].createElement(React.Fragment, { key: "success" },
                    React__default['default'].createElement(Success, { fontSize: "inherit", animation: true }),
                    React__default['default'].createElement("span", { className: "easy-scroll-down-inner-text" }, "\u5237\u65B0\u6210\u529F")));
            }
            if (status === 7) {
                return (React__default['default'].createElement(React.Fragment, { key: "error" },
                    React__default['default'].createElement(Error$1, { fontSize: "inherit", animation: true }),
                    React__default['default'].createElement("span", { className: "easy-scroll-down-inner-text" }, "\u5237\u65B0\u5931\u8D25")));
            }
            return null;
        }, [status, perimeter]);
        var setRotate = React.useCallback(function () {
            // 无限旋转
            if (dragInnerRef.current) {
                rotate.current += 9000;
                dragInnerRef.current.style.transform = "rotate(" + rotate.current + "deg)";
            }
        }, []);
        React.useEffect(function () {
            var timer = null;
            if (status === 4 && dragInnerRef.current) {
                // 正在刷新启用无限旋转
                dom.classListAdd(dragInnerRef.current, 'easy-scroll-down-inner-refreshing');
                setRotate();
                timer = setInterval(function () {
                    setRotate();
                }, 20000);
            }
            return function () {
                if (timer !== null) {
                    clearInterval(timer);
                    timer = null;
                }
            };
        }, [status, setRotate]);
        React.useImperativeHandle(ref, function () { return ({
            setHeight: function (height) {
                if (dragCircleRef.current) {
                    if (height >= fontSize) {
                        // 如果高度超出了最低限 开始计算周长 这样可以确保用户能清楚的看到圆弧成长的整个过程
                        var cp = (showMaxPerimeter / beginShowHeight) * (height - fontSize); // 计算周长
                        if (cp > showMaxPerimeter) { // 周长限定的最大值
                            cp = showMaxPerimeter;
                        }
                        var opacity = cp / perimeter + 0.2; // 计算透明度 从0.2开始
                        if (opacity > 0.9) { // 不允许超过限度
                            opacity = 0.9;
                        }
                        dragCircleRef.current.style.strokeOpacity = "" + opacity; // 透明度
                        dragCircleRef.current.style.strokeDashoffset = perimeter - cp + "px"; // 圈大小
                    }
                    else {
                        // 如果没达到要求置为不可显示状态
                        dragCircleRef.current.style.strokeOpacity = '0';
                        dragCircleRef.current.style.strokeDashoffset = perimeter + "px";
                    }
                    if (height > offset && status === 2 && dragInnerRef.current) {
                        // 超过了临界值 并且还在下拉 开始旋转效果
                        rotate.current = -90 + (height - offset) / outOffsetRate;
                        dragInnerRef.current.style.transform = "rotate(" + rotate.current + "deg)";
                    }
                }
                // 设置下拉刷新盒子高度
                if (downRef.current) {
                    downRef.current.style.height = height + "px";
                }
            }
        }); });
        return (React__default['default'].createElement("div", { ref: downRef, className: "easy-scroll-down easy-scroll-hardware" },
            React__default['default'].createElement("div", { className: "easy-scroll-down-inner easy-flex-center", style: { fontSize: fontSize } }, getRefreshDOM)));
    }

    // 加载中
    function Loading(props) {
        var _a = props.fontSize, fontSize = _a === void 0 ? 30 : _a, _b = props.color, color = _b === void 0 ? '#999999' : _b, _c = props.animation, animation = _c === void 0 ? false : _c;
        var allowAnimation = React.useMemo(function () { return animation; }, [animation]);
        var p = React.useMemo(function () { return 2 * Math.PI * 150 * 0.8; }, []); // 周长
        return (React__default['default'].createElement("svg", __assign({}, svgAttr, { fontSize: fontSize, color: color, className: classnames(svgAttr.className, { 'easy-icon-loading': allowAnimation }) }),
            React__default['default'].createElement("circle", { cx: "200", cy: "200", r: "150", stroke: "currentColor", fill: "transparent", strokeWidth: "20", strokeDasharray: p })));
    }

    function Up(props) {
        var status = props.status;
        var upRef = React.useRef(null); // 下拉刷新盒子容器
        var getLoadDOM = React.useMemo(function () {
            if (status === 1) {
                return React__default['default'].createElement(React.Fragment, { key: "loading" },
                    React__default['default'].createElement(Loading, { fontSize: "inherit", color: "inherit", animation: true }),
                    React__default['default'].createElement("span", { className: "easy-scroll-up-load-text" }, "\u52A0\u8F7D\u4E2D..."));
            }
            if (status === 2) {
                return React__default['default'].createElement(React.Fragment, { key: "success" },
                    React__default['default'].createElement(Success, { fontSize: "inherit", animation: true }),
                    React__default['default'].createElement("span", { className: "easy-scroll-up-load-text" }, "\u52A0\u8F7D\u6210\u529F"));
            }
            if (status === 3) {
                return React__default['default'].createElement(React.Fragment, { key: "error" },
                    React__default['default'].createElement(Error$1, { fontSize: "inherit", animation: true }),
                    React__default['default'].createElement("span", { className: "easy-scroll-up-load-text" }, "\u52A0\u8F7D\u5931\u8D25"));
            }
            if (status === 4) {
                return React__default['default'].createElement(React.Fragment, { key: "no-more" },
                    React__default['default'].createElement("span", { className: "easy-scroll-up-load-text" }, "\u6CA1\u6709\u66F4\u591A\u4E86..."));
            }
            return null;
        }, [status]);
        React.useEffect(function () {
            if (upRef.current) {
                if (status === 0) {
                    upRef.current.style.visibility = 'hidden';
                }
                else {
                    upRef.current.style.visibility = 'visible';
                }
            }
        }, [status]);
        return (React__default['default'].createElement("div", { ref: upRef, className: "easy-scroll-up easy-scroll-hardware" }, getLoadDOM));
    }

    var t=useParamFnFreeze,n=usePassiveSupported,i=utils;function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(t),a=o(n),u=function(){return (u=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function c(e,t){var n=!1;if(e instanceof MouseEvent)n=!0;else for(var i=0;i<e.changedTouches.length;i+=1)e.changedTouches[i].identifier===t&&(n=!0);return n}function s(e,t){return !(!e||!/^touch/.test(t.type))&&i.preventDefault(t)}var v=0;function d(e,t,n){var i=e.getAttribute(t),o=i;return i||(i=void 0===n?(v+=1).toString():n,e.setAttribute(t,i)),{active:i,old:o}}function h(e,t){var n=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);return Math.sqrt(Math.pow(n,2)+Math.pow(i,2))}var m={minTime:0,maxTime:300,minMove:0,maxMove:2};var g={minTime:0,maxTime:300,minMove:0,maxMove:2,timeSpan:400};var f={minTime:500,maxTime:1/0,minMove:0,maxMove:4};var l={minTime:500,minMove:0,maxMove:4};var p=10,T={left:{count:0,disabled:!1},right:{count:0,disabled:!1},up:{count:0,disabled:!1},down:{count:0,disabled:!1},trigger:""};function w(e){var t=i.getClientPos(e),n={x:t.clientX,y:t.clientY,time:e.timeStamp},o=i.getEventId(e),r=JSON.parse(JSON.stringify(T));return function(t){var a=t.left,v=void 0===a?{}:a,d=t.right,h=void 0===d?{}:d,m=t.up,g=void 0===m?{}:m,f=t.down,l=void 0===f?{}:f,T=t.swipePreventDefault,w=t.swipeMeanwhileTrigger,y=v.minMove,E=void 0===y?p:y,x=h.minMove,L=void 0===x?p:x,M=g.minMove,b=void 0===M?p:M,S=l.minMove,P=void 0===S?p:S;return function(t,a){var v=u({},n);function d(e){if(c(e,o)){if(e instanceof MouseEvent){var a=i.getClientPos(e);v={x:a.clientX,y:a.clientY,time:e.timeStamp};}else for(var u=0;u<e.changedTouches.length;u+=1)e.changedTouches[u].identifier===o&&(v={x:e.changedTouches[u].clientX,y:e.changedTouches[u].clientY,time:e.timeStamp});var d,h,m=i.inclinedAngle(n,v);if(t.left&&(w||["","left"].indexOf(r.trigger)>-1))(d=v.x-n.x)<0&&Math.abs(d)>=E?(0===r.left.count&&(r.left.disabled=!(m>135&&m<225),r.left.count+=1),!1===r.left.disabled&&(s(T,e),r.trigger="left",t.left(e,Math.abs(d)-E))):!1===w&&"left"===r.trigger&&(s(T,e),t.left(e,-1*(d+E)));if(t.right&&(w||["","right"].indexOf(r.trigger)>-1))(d=v.x-n.x)>0&&d>=L?(0===r.right.count&&(r.right.disabled=!(m>315||m<45),r.right.count+=1),!1===r.right.disabled&&(s(T,e),r.trigger="right",t.right(e,d-L))):!1===w&&"right"===r.trigger&&(s(T,e),t.right(e,d-L));if(t.up&&(w||["","up"].indexOf(r.trigger)>-1))(h=v.y-n.y)<0&&Math.abs(h)>=b?(0===r.up.count&&(r.up.disabled=!(m>225&&m<315),r.up.count+=1),!1===r.up.disabled&&(s(T,e),r.trigger="up",t.up(e,Math.abs(h)-b))):!1===w&&"up"===r.trigger&&(s(T,e),t.up(e,-1*(h+b)));if(t.down&&(w||["","down"].indexOf(r.trigger)>-1))(h=v.y-n.y)>0&&h>=P?(0===r.down.count&&(r.down.disabled=!(m>45&&m<135),r.down.count+=1),!1===r.down.disabled&&(s(T,e),r.trigger="down",t.down(e,h-P))):!1===w&&"down"===r.trigger&&(s(T,e),t.down(e,h-P));}}function h(e){c(e,o)&&function(e){i.haveToWindow()&&(window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",h),e.target&&(e.target.removeEventListener("touchmove",d),e.target.removeEventListener("touchend",h),e.target.removeEventListener("touchcancel",h)));}(e);}i.haveToWindow()&&(window.addEventListener("mousemove",d),window.addEventListener("mouseup",h),e.target&&(e.target.addEventListener("touchmove",d,a),e.target.addEventListener("touchend",h),e.target.addEventListener("touchcancel",h)));}}}function y(e,t){for(var n=[],i=0;i<t.length;i+=1)e.indexOf(t[i].identifier)>-1&&n.push(t[i]);return n}var E={};var lib=function(t){var n=t.children,o=t.tapPreventDefault,v=void 0!==o&&o,p=t.longPressPreventDefault,T=void 0!==p&&p,x=t.swipePreventDefault,L=void 0!==x&&x,M=t.swipeEntirelyPreventDefault,b=void 0!==M&&M,S=t.scalePreventDefault,P=void 0!==S&&S,O=a.default(),X=React__default['default'].useMemo((function(){return !(v||T||L||b||P)}),[v,T,L,b,P]),Y=React__default['default'].useMemo((function(){return !!O&&{passive:X}}),[O,X]),D=r.default(i.exclude(t,"children")),C=React__default['default'].useRef((function(){return D.current})),H=React__default['default'].useRef(null),W=React__default['default'].useCallback((function(e){var t=!0;if(e instanceof MouseEvent){if(H.current){var n=H.current.t;e.timeStamp-n<=800&&(t=!1);}H.current=null;}else 1===e.changedTouches.length&&(H.current={t:e.timeStamp});if(t){var o=C.current(),r=o.onTap,a=o.onDoubleTap,v=o.onLongPress,p=o.onLongPressUp,T=o.onSwipeLeft,x=o.onSwipeRight,L=o.onSwipeUp,M=o.onSwipeDown,b=o.onScale,S=o.tapPreventDefault,P=void 0!==S&&S,O=o.longPressPreventDefault,X=void 0!==O&&O,D=o.swipePreventDefault,W=void 0!==D&&D,A=o.swipeEntirelyPreventDefault,q=void 0!==A&&A,I=o.scalePreventDefault,j=void 0!==I&&I,k=o.tapOptions,N=o.doubleTapOptions,R=o.longPressUpOptions,U=o.longPressOptions,F=o.swipeMeanwhileTrigger,J=void 0!==F&&F,z=o.swipeLeftOptions,B=o.swipeRightOptions,G=o.swipeUpOptions,K=o.swipeDownOptions;r&&(s(P,e),function(e){var t=i.getClientPos(e),n={x:t.clientX,y:t.clientY,time:e.timeStamp},o=i.getEventId(e);return function(t){void 0===t&&(t=m);var r=t.minTime,a=void 0===r?m.minTime:r,s=t.maxTime,v=void 0===s?m.maxTime:s,d=t.minMove,h=void 0===d?m.minMove:d,g=t.maxMove,f=void 0===g?m.maxMove:g;return function(t){var r=u({},n);function s(e){if(c(e,o)){if(e instanceof MouseEvent)r={x:e.clientX,y:e.clientY,time:e.timeStamp};else for(var i=0;i<e.changedTouches.length;i+=1)e.changedTouches[i].identifier===o&&(r={x:e.changedTouches[i].clientX,y:e.changedTouches[i].clientY,time:e.timeStamp});m(e);var u=Math.abs(r.x-n.x),s=Math.abs(r.y-n.y),d=Math.abs(r.time-n.time);u>=h&&u<=f&&s>=h&&s<=f&&d>=a&&d<=v&&t(e);}}function d(e){c(e,o)&&m(e);}function m(e){i.haveToWindow()&&(window.removeEventListener("mouseup",s),e.target&&(e.target.removeEventListener("touchend",s),e.target.removeEventListener("touchcancel",d)));}i.haveToWindow()&&(window.addEventListener("mouseup",s),e.target&&(e.target.addEventListener("touchend",s),e.target.addEventListener("touchcancel",d)));}}}(e)(k)(r)),a&&(s(P,e),function(e){var t=i.getClientPos(e),n={x:t.clientX,y:t.clientY,time:e.timeStamp},o=i.getEventId(e);return function(t){void 0===t&&(t=g);var r=t.minTime,a=void 0===r?g.minTime:r,s=t.maxTime,v=void 0===s?g.maxTime:s,h=t.minMove,m=void 0===h?g.minMove:h,f=t.maxMove,l=void 0===f?g.maxMove:f,p=t.timeSpan,T=void 0===p?g.timeSpan:p;return function(t){var r=u({},n),s=e.currentTarget;function h(e){if(c(e,o)){if(e instanceof MouseEvent)r={x:e.clientX,y:e.clientY,time:e.timeStamp};else for(var i=0;i<e.changedTouches.length;i+=1)e.changedTouches[i].identifier===o&&(r={x:e.changedTouches[i].clientX,y:e.changedTouches[i].clientY,time:e.timeStamp});f(e);var u=Math.abs(r.x-n.x),h=Math.abs(r.y-n.y),g=Math.abs(r.time-n.time);if(u>=m&&u<=l&&h>=m&&h<=l&&g>=a&&g<=v&&s){var p=d(s,"data-easy-event-tap-count","1"),w=d(s,"data-easy-event-tap-time",e.timeStamp.toString());if("1"===p.old)e.timeStamp-Number(w.old)<=T?(s.removeAttribute("data-easy-event-tap-count"),s.removeAttribute("data-easy-event-tap-time"),t(e)):(s.setAttribute("data-easy-event-tap-count","1"),s.setAttribute("data-easy-event-tap-time",e.timeStamp.toString()));}}}function g(e){c(e,o)&&f(e);}function f(e){i.haveToWindow()&&(window.removeEventListener("mouseup",h),e.target&&(e.target.removeEventListener("touchend",h),e.target.removeEventListener("touchcancel",g)));}i.haveToWindow()&&(window.addEventListener("mouseup",h),e.target&&(e.target.addEventListener("touchend",h),e.target.addEventListener("touchcancel",g)));}}}(e)(N)(a)),p&&(s(X,e),function(e){var t=i.getClientPos(e),n={x:t.clientX,y:t.clientY,time:e.timeStamp},o=i.getEventId(e);return function(t){void 0===t&&(t=f);var r=t.minTime,a=void 0===r?f.minTime:r,s=t.maxTime,v=void 0===s?f.maxTime:s,d=t.minMove,h=void 0===d?f.minMove:d,m=t.maxMove,g=void 0===m?f.maxMove:m;return function(t){var r=u({},n);function s(e){if(c(e,o)){if(e instanceof MouseEvent){var u=i.getClientPos(e);r={x:u.clientX,y:u.clientY,time:e.timeStamp};}else for(var s=0;s<e.changedTouches.length;s+=1)e.changedTouches[s].identifier===o&&(r={x:e.changedTouches[s].clientX,y:e.changedTouches[s].clientY,time:e.timeStamp});m(e);var d=Math.abs(r.x-n.x),f=Math.abs(r.y-n.y),l=Math.abs(r.time-n.time);d>=h&&d<=g&&f>=h&&f<=g&&l>=a&&l<=v&&t(e);}}function d(e){c(e,o)&&m(e);}function m(e){i.haveToWindow()&&(window.removeEventListener("mouseup",s),e.target&&(e.target.removeEventListener("touchend",s),e.target.removeEventListener("touchcancel",d)));}i.haveToWindow()&&(window.addEventListener("mouseup",s),e.target&&(e.target.addEventListener("touchend",s),e.target.addEventListener("touchcancel",d)));}}}(e)(R)(p)),v&&(s(X,e),function(e){var t=i.getClientPos(e),n={x:t.clientX,y:t.clientY},o=i.getEventId(e);return function(t){void 0===t&&(t=l);var r=t.minTime,a=void 0===r?l.minTime:r,s=t.minMove,v=void 0===s?l.minMove:s,d=t.maxMove,h=void 0===d?l.maxMove:d;return function(t,r){var s=null,d=u({},n);function m(e){if(e instanceof MouseEvent){var t=i.getClientPos(e);d={x:t.clientX,y:t.clientY};}else for(var n=0;n<e.changedTouches.length;n+=1)e.changedTouches[n].identifier===o&&(d={x:e.changedTouches[n].clientX,y:e.changedTouches[n].clientY});}function g(e){c(e,o)&&f(e);}function f(e){clearTimeout(Number(s)),i.haveToWindow()&&(window.removeEventListener("mousemove",m),window.removeEventListener("mouseup",g),e.target&&(e.target.removeEventListener("touchmove",m),e.target.removeEventListener("touchend",g),e.target.removeEventListener("touchcancel",g)));}e.target&&(s=setTimeout((function(){var i=Math.abs(d.x-n.x),o=Math.abs(d.y-n.y);i>=v&&i<=h&&o>=v&&o<=h&&(f(e),t(e));}),a),i.haveToWindow()&&(window.addEventListener("mousemove",m),window.addEventListener("mouseup",g),e.target&&(e.target.addEventListener("touchmove",m,r),e.target.addEventListener("touchend",g),e.target.addEventListener("touchcancel",g))));}}}(e)(U)(v,Y));var Q={swipePreventDefault:W,swipeMeanwhileTrigger:J},V={};T&&(s(q,e),Q.left=z,V.left=T),x&&(s(q,e),Q.right=B,V.right=x),L&&(s(q,e),Q.up=G,V.up=L),M&&(s(q,e),Q.down=K,V.down=M),Object.keys(V).length&&w(e)(Q)(V,Y),!b||e instanceof MouseEvent||(s(j,e),function(e){var t=d(e.currentTarget,"data-easy-event-scale-id").active;E[t]||(E[t]={finger:[],startTouches:[],moveTouches:[],startHypotenuseLength:0,moveHypotenuseLength:0}),function(e,t,n){for(var i=0;i<n.changedTouches.length&&2!==e[t].finger.length;i+=1)e[t].finger.push(n.changedTouches[i].identifier);}(E,t,e);for(var n=[],i=0;i<e.changedTouches.length;i+=1)n.push(e.changedTouches[i].identifier);return function(){return function(n,i){function o(e){if(E[t]&&2===E[t].finger.length){for(var i=!1,o=0;o<e.changedTouches.length;o+=1)E[t].finger.indexOf(e.changedTouches[o].identifier)>-1&&(i=!0);if(i){var r=E[t].moveTouches=y(E[t].finger,e.touches),a=r[0],u=r[1];E[t].moveHypotenuseLength=h({x:a.clientX,y:a.clientY},{x:u.clientX,y:u.clientY}),n({type:"move",startTouches:E[t].startTouches,moveTouches:E[t].moveTouches,scale:E[t].moveHypotenuseLength/E[t].startHypotenuseLength});}}}function r(e){var i=void 0===E[t];if(!i)for(var a=0;a<e.changedTouches.length;a+=1)E[t].finger.indexOf(e.changedTouches[a].identifier)>-1&&(i=!0);i&&e.target&&(e.target.removeEventListener("touchmove",o),e.target.removeEventListener("touchend",r),e.target.removeEventListener("touchcancel",r)),i&&E[t]&&(2===E[t].finger.length&&n({type:"end",startTouches:E[t].startTouches,moveTouches:E[t].moveTouches,scale:E[t].moveHypotenuseLength/E[t].startHypotenuseLength}),delete E[t]);}for(var a=!1,u=0;u<e.changedTouches.length;u+=1)E[t].finger.indexOf(e.changedTouches[u].identifier)>-1&&(a=!0);if(a&&e.target){if(2===E[t].finger.length){var c=E[t].startTouches=y(E[t].finger,e.touches),s=c[0],v=c[1];E[t].moveTouches=E[t].startTouches,E[t].startHypotenuseLength=h({x:s.clientX,y:s.clientY},{x:v.clientX,y:v.clientY}),E[t].moveHypotenuseLength=E[t].startHypotenuseLength,n({type:"start",startTouches:E[t].startTouches,moveTouches:E[t].moveTouches,scale:1});}e.target.addEventListener("touchmove",o,i),e.target.addEventListener("touchend",r),e.target.addEventListener("touchcancel",r);}}}}(e)()(b,Y));}}),[Y]),A=React__default['default'].useState(),q=A[0],I=A[1];React__default['default'].useEffect((function(){return q&&(i.isPC()&&q.addEventListener("mousedown",W),q.addEventListener("touchstart",W,Y)),function(){q&&(q.removeEventListener("mousedown",W),q.removeEventListener("touchstart",W));}}),[W,q,Y]);var j=React__default['default'].useMemo((function(){return {ref:function(e){n.ref&&("function"==typeof n.ref?n.ref(e):n.ref.current=e),I(e);}}}),[n]);return React__default['default'].cloneElement(React__default['default'].Children.only(n),j)};

    var start = null;
    var move = null;
    // 拖动事件
    function handleMove(e, pos, button) {
        utils.preventDefault(e); // 拖动时组织默认事件
        var _a = utils.getClientPos(e), clientX = _a.clientX, clientY = _a.clientY;
        var posX = pos.posX, posY = pos.posY, width = pos.width, height = pos.height;
        // 限制移动范围 只能在屏幕内
        var left = clientX - posX;
        if (left < 0) {
            left = 0;
        }
        else if (left > document.documentElement.clientWidth - width) {
            left = document.documentElement.clientWidth - width;
        }
        var top = clientY - posY;
        if (top < 0) {
            top = 0;
        }
        else if (top > document.documentElement.clientHeight - height) {
            top = document.documentElement.clientHeight - height;
        }
        // 设置位置
        button.style.position = 'fixed';
        button.style.left = left + "px";
        button.style.top = top + "px";
        button.style.marginTop = '0px';
    }
    // 取消事件
    function handleEnd() {
        // 解绑各个时间
        if (utils.haveToWindow()) {
            window.removeEventListener('mousemove', move);
            window.removeEventListener('mouseup', handleEnd);
            window.removeEventListener('touchmove', move);
            window.removeEventListener('touchend', handleEnd);
            window.removeEventListener('touchcancel', handleEnd);
        }
    }
    // 按下事件
    function handleStart(e, childrenNotAllowDown, eventOptions) {
        utils.preventDefault(e); // 按下的时候阻止默认事件
        var _a = utils.getClientPos(e), clientX = _a.clientX, clientY = _a.clientY;
        var button = dom.findParentNode(e.target, 'easy-scroll-side-button-drag'); // 判断当前元素是不是抖动状态
        if (button) {
            // 按下的抖动元素
            var buttonRect = dom.getStyleValue(button);
            if (buttonRect) {
                var pos_1 = {
                    posX: clientX - buttonRect.left,
                    posY: clientY - buttonRect.top,
                    width: buttonRect.width,
                    height: buttonRect.height
                };
                move = function (event) {
                    handleMove(event, pos_1, button);
                };
            }
            // 按下的时候再次绑定事件
            if (utils.haveToWindow()) {
                window.addEventListener('mousemove', move);
                window.addEventListener('mouseup', handleEnd);
                // 移动端事件
                window.addEventListener('touchmove', move, eventOptions);
                window.addEventListener('touchend', handleEnd);
                window.addEventListener('touchcancel', handleEnd);
            }
        }
        else { // 如果不是抖动元素 则进入
            childrenNotAllowDown.current = false; // ScrollView重置为可操作
            // 所有的抖动元素都取消抖动
            var drags = document.querySelectorAll('.easy-scroll-side-button-drag');
            for (var i = 0; i < drags.length; i += 1) {
                drags[i].classList.remove('easy-scroll-side-button-drag');
            }
            // 删除事件
            if (utils.haveToWindow()) {
                window.removeEventListener('mousedown', start);
                window.removeEventListener('touchstart', start);
            }
        }
    }
    // 长按事件
    function longPressButton(e, childrenNotAllowDown, eventOptions) {
        // 获取位置信息
        var _a = utils.getClientPos(e), clientX = _a.clientX, clientY = _a.clientY;
        var button = dom.findParentNode(e.target, 'easy-scroll-side-button'); // 查找到按钮节点
        if (button && !button.classList.contains('easy-scroll-side-button-drag')) { // 如果找到了 看看是不是已经在抖动状态
            var buttonRect = dom.getStyleValue(button); // 不在就往下进行
            if (buttonRect) {
                // showToast({
                //   title: '可以拖动了~',
                //   icon: 'none',
                //   duration: 1000
                // });
                childrenNotAllowDown.current = true; // 如果触发了长按事件 则禁用下拉刷新
                button.classList.add('easy-scroll-side-button-drag'); // 修改为抖动状态
                // 按钮当前位置
                var pos_2 = {
                    posX: clientX - buttonRect.left,
                    posY: clientY - buttonRect.top,
                    width: buttonRect.width,
                    height: buttonRect.height
                };
                start = function (event) {
                    handleStart(event, childrenNotAllowDown, eventOptions);
                };
                move = function (event) {
                    handleMove(event, pos_2, button);
                };
                // PC端事件
                if (utils.haveToWindow()) {
                    window.addEventListener('mousedown', start);
                    window.addEventListener('mousemove', move);
                    window.addEventListener('mouseup', handleEnd);
                    // 移动端事件
                    window.addEventListener('touchstart', start, eventOptions);
                    window.addEventListener('touchmove', move, eventOptions);
                    window.addEventListener('touchend', handleEnd);
                    window.addEventListener('touchcancel', handleEnd);
                }
            }
        }
    }

    function SideButton(props) {
        // 删除不属于button的属性
        var buttonProps = __assign(__assign({}, props), { onTap: undefined, childrenNotAllowDown: undefined, inlayType: undefined, index: undefined });
        delete buttonProps.onTap;
        delete buttonProps.childrenNotAllowDown;
        delete buttonProps.inlayType;
        delete buttonProps.index;
        var passiveSupported = usePassiveSupported(); // 检测是否支持{ passive: false }
        var eventOptions = React.useMemo(function () { return passiveSupported ? { passive: false } : false; }, [passiveSupported]);
        return (React__default['default'].createElement(lib, { longPressPreventDefault: true, onLongPress: function (event) {
                longPressButton(event, props.childrenNotAllowDown, eventOptions);
            }, onTap: function (event) {
                var button = dom.findParentNode(event.target, 'easy-scroll-side-button-drag'); // 判断当前元素是不是抖动状态
                if (!button) {
                    // 非抖动状态才可以触发onTap
                    if (props.onTap) {
                        props.onTap();
                    }
                }
            } },
            React__default['default'].createElement("button", __assign({ className: "easy-scroll-side-button" }, buttonProps))));
    }

    // 回到顶部
    function Top(props) {
        var _a = props.fontSize, fontSize = _a === void 0 ? 30 : _a, _b = props.color, color = _b === void 0 ? 'inherit' : _b, _c = props.animation, animation = _c === void 0 ? false : _c;
        var allowAnimation = React.useMemo(function () { return utils.getBrowserVersion() !== 'IE' && animation; }, [animation]);
        var lineOffset = React.useMemo(function () { return allowAnimation ? 300 : 0; }, [allowAnimation]);
        return (React__default['default'].createElement("svg", __assign({}, svgAttr, { fontSize: fontSize, color: color }),
            React__default['default'].createElement("line", { className: classnames({ 'easy-icon-animation': allowAnimation }), strokeLinecap: "round", stroke: "currentColor", strokeWidth: "20", x1: "140", y1: "100", x2: "260", y2: "100", strokeDashoffset: lineOffset, strokeDasharray: "300" }),
            React__default['default'].createElement("line", { className: classnames({ 'easy-icon-animation': allowAnimation }, 'easy-icon-animation-delay005'), strokeLinecap: "round", stroke: "currentColor", strokeWidth: "20", x1: "200", y1: "140", x2: "100", y2: "220", strokeDashoffset: lineOffset, strokeDasharray: "300" }),
            React__default['default'].createElement("line", { className: classnames({ 'easy-icon-animation': allowAnimation }, 'easy-icon-animation-delay010'), strokeLinecap: "round", stroke: "currentColor", strokeWidth: "20", x1: "200", y1: "140", x2: "300", y2: "220", strokeDashoffset: lineOffset, strokeDasharray: "300" }),
            React__default['default'].createElement("line", { className: classnames({ 'easy-icon-animation': allowAnimation }, 'easy-icon-animation-delay015'), strokeLinecap: "round", stroke: "currentColor", strokeWidth: "20", x1: "200", y1: "140", x2: "200", y2: "300", strokeDashoffset: lineOffset, strokeDasharray: "300" })));
    }

    // 回到顶部按钮
    function SideTheTopButton(props) {
        var buttonProps = __assign(__assign({}, props), { onTap: undefined, childrenNotAllowDown: undefined, inlayType: undefined, index: undefined });
        delete buttonProps.onTap;
        delete buttonProps.childrenNotAllowDown;
        delete buttonProps.inlayType;
        delete buttonProps.index;
        var passiveSupported = usePassiveSupported(); // 检测是否支持{ passive: false }
        var eventOptions = React.useMemo(function () { return passiveSupported ? { passive: false } : false; }, [passiveSupported]);
        var toTheTop = React.useCallback(function () {
            var viewRef = document.querySelector('.easy-scroll-view');
            if (viewRef) {
                slideTo.slideTo({
                    startPos: viewRef.scrollTop,
                    endPos: 0,
                    chunkCallback: function (nextScrollTop) {
                        // 不断靠近
                        viewRef.scrollTop = nextScrollTop;
                    },
                    completeCallback: function (endPos) {
                        // 到达
                        viewRef.scrollTop = endPos;
                    }
                });
            }
        }, []);
        // 监听滚动事件 做显示隐藏
        var _a = React.useState(false), visible = _a[0], setVisible = _a[1]; // 显示隐藏
        var handleScroll = React.useCallback(function () {
            var viewRef = document.querySelector('.easy-scroll-view');
            if (viewRef && viewRef.scrollTop > 100) {
                setVisible(true);
            }
            else {
                setVisible(false);
            }
        }, []);
        var scrollDestroy = React.useCallback(function () {
            var viewRef = document.querySelector('.easy-scroll-view');
            if (viewRef) {
                viewRef.removeEventListener('scroll', handleScroll);
            }
        }, [handleScroll]);
        React.useEffect(function () {
            var viewRef = document.querySelector('.easy-scroll-view');
            if (viewRef) {
                handleScroll();
                viewRef.addEventListener('scroll', handleScroll);
            }
            return scrollDestroy;
        }, [handleScroll, scrollDestroy]);
        return (visible ? (React__default['default'].createElement(lib, { longPressPreventDefault: true, onLongPress: function (event) {
                longPressButton(event, props.childrenNotAllowDown, eventOptions);
            }, onTap: function (event) {
                var button = dom.findParentNode(event.target, 'easy-scroll-side-button-drag'); // 判断当前元素是不是抖动状态
                if (!button) {
                    // 非抖动状态才可以触发onTap 
                    var flag = void 0;
                    if (props.onTap) {
                        flag = props.onTap();
                    }
                    if (flag === undefined || flag) {
                        // 如果返回 false 则不调用回到顶部
                        toTheTop();
                    }
                }
            } },
            React__default['default'].createElement("button", __assign({ className: "easy-scroll-side-button" }, buttonProps),
                React__default['default'].createElement(Top, { animation: true })))) : React__default['default'].createElement(React__default['default'].Fragment, null));
    }

    function Side(props) {
        var _a = props.right, right = _a === void 0 ? 10 : _a, _b = props.bottom, bottom = _b === void 0 ? 40 : _b, button = props.button, childrenNotAllowDown = props.childrenNotAllowDown;
        // 分类渲染按钮
        function getButton(b, index) {
            var btnProps = __assign(__assign({ key: index }, b), { index: index,
                childrenNotAllowDown: childrenNotAllowDown });
            if (b.inlayType === 'theTop') { // 回到顶部按钮
                return (React__default['default'].createElement(SideTheTopButton, __assign({}, btnProps)));
            }
            return ( // 普通按钮
            React__default['default'].createElement(SideButton, __assign({}, btnProps)));
        }
        return (React__default['default'].createElement("div", { className: "easy-scroll-side", style: {
                right: right,
                bottom: bottom,
            } }, (function () {
            if (button) {
                if (Array.isArray(button)) {
                    return button.map(function (item, index) { return getButton(item, button.length - index); });
                }
                return getButton(button, 0);
            }
            return null;
        })()));
    }

    function ScrollView(props, ref) {
        var children = props.children, _a = props.down, down = _a === void 0 ? {} : _a, _b = props.up, up = _b === void 0 ? {} : _b, _c = props.lazy, lazy = _c === void 0 ? {} : _c, _d = props.side, side = _d === void 0 ? {} : _d;
        var passiveSupported = usePassiveSupported(); // 检测是否支持{ passive: false }
        var eventOptions = React.useMemo(function () { return passiveSupported ? { passive: false } : false; }, [passiveSupported]);
        var firstEntry = React.useRef(true); // 是否初次进入
        var view = React.useRef(null); // 最外层盒子容器
        /**
         * @name 公共状态，此时下拉刷新与上拉加载都不触发
         * 有时候子节点需要做操作 但又不想触发下拉刷新与上拉加载
         */
        var childrenNotAllowDown = React.useRef(false);
        /**
         * @name 下拉状态 注：所有的状态都会回到0
         * @param 无操作 0
         * @param 下拉-未达到刷新条件 1
         * @param 下拉-达到刷新条件 2
         * @param 释放-回弹至刷新中 3
         * @param 刷新中 4
         * @param 刷新成功 5
         * @param 释放-回弹至初始位置 6
         * @param 刷新失败 7
         */
        var _e = React.useState(0), downStatus = _e[0], setDownStatus = _e[1];
        var downState = useParamFnFreeze({
            downStatus: downStatus,
        });
        var getDownState = React.useRef(function () { return downState.current; }); // 为了在副作用函数上少写依赖
        /**
          * @name 上拉状态
          * @param 无操作 0
          * @param 正在加载 1
          * @param 加载成功 2
          * @param 加载失败 3
          * @param 到底了 4
          */
        var _f = React.useState(0), upStatus = _f[0], setUpStatus = _f[1];
        var upState = useParamFnFreeze({
            upStatus: upStatus,
        });
        var getUpState = React.useRef(function () { return upState.current; }); // 为了在副作用函数上少写依赖
        // 下拉
        var _g = down.enable, downEnable = _g === void 0 ? true : _g, _h = down.offset, downOffset = _h === void 0 ? 80 : _h, _j = down.outOffsetRate, downOutOffsetRate = _j === void 0 ? 0.2 : _j, _k = down.successStay, downSuccessStay = _k === void 0 ? 800 : _k, downRefreshing = down.refreshing, DownCustom = down.custom;
        var downParams = useParamFnFreeze({
            downEnable: downEnable,
            downOffset: downOffset,
            downOutOffsetRate: downOutOffsetRate,
            downSuccessStay: downSuccessStay,
            downRefreshing: downRefreshing
        });
        var getDownParams = React.useRef(function () { return downParams.current; }); // 为了在副作用函数上少写依赖
        var downMoveData = React.useRef({
            start: { x: 0, y: 0 },
            prev: { x: 0, y: 0 },
            curve: { x: 0, y: 0 }
        });
        var downRef = React.useRef(); // 下拉刷新盒子
        var downHeight = React.useRef(0); // 下拉刷新盒子容器高度
        var downAllow = React.useRef(false); // 是否允许执行下拉功能 用来做一些额外的限制
        var downTimer = React.useRef(null); // 下拉释放后回弹的定时器
        var downClearTimer = React.useRef(function () {
            if (downTimer.current) {
                downTimer.current();
                downTimer.current = null;
            }
        });
        var downTouchmoveCount = React.useRef(0); // 下拉手指移动次数
        var downEventTarget = React.useRef(null); // 已绑定事件的对象 用于后面的手指按下时解绑前面的手指
        // 下拉刷新逻辑
        var toRefresh = React.useRef(function () {
            setDownStatus(3);
            downClearTimer.current();
            downTimer.current = slideTo.slideTo({
                startPos: downHeight.current,
                endPos: downOffset,
                chunkCallback: function (nextScrollTop) {
                    // 不断靠近
                    if (downRef.current) {
                        downHeight.current = nextScrollTop;
                        downRef.current.setHeight(nextScrollTop);
                    }
                },
                completeCallback: function (endPos) {
                    // 到达 开始执行刷新
                    if (downRef.current) {
                        downHeight.current = endPos;
                        downRef.current.setHeight(endPos);
                    }
                    setDownStatus(4);
                    var downRefreshing = getDownParams.current().downRefreshing;
                    if (downRefreshing) {
                        downRefreshing();
                    }
                }
            });
        });
        var toInitial = React.useRef(function () {
            setDownStatus(6);
            downClearTimer.current();
            downTimer.current = slideTo.slideTo({
                startPos: downHeight.current,
                endPos: 0,
                chunkCallback: function (nextScrollTop) {
                    // 不断靠近
                    if (downRef.current) {
                        downHeight.current = nextScrollTop;
                        downRef.current.setHeight(nextScrollTop);
                    }
                },
                completeCallback: function (endPos) {
                    // 到达原始位置
                    if (downRef.current) {
                        downHeight.current = endPos;
                        downRef.current.setHeight(endPos);
                    }
                    setDownStatus(0);
                }
            });
        });
        var downComplete = React.useCallback(function (_a) {
            var success = _a.success;
            var downSuccessStay = getDownParams.current().downSuccessStay;
            if (success) {
                setDownStatus(5); // 刷新成功
            }
            else {
                setDownStatus(7); // 刷新失败
            }
            // 短暂驻留功能
            if (downSuccessStay > 0) {
                setTimeout(function () {
                    toInitial.current();
                }, downSuccessStay);
            }
            else {
                toInitial.current();
            }
        }, []);
        // 事件
        var customDownMove = React.useCallback(function (detail) {
            var _a;
            if (utils.haveToWindow() && window.CustomEvent) {
                var event_1 = new window.CustomEvent("custom-down-touchmove", {
                    detail: detail
                });
                (_a = view.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(event_1);
            }
        }, []);
        var customDownStop = React.useCallback(function (detail) {
            var _a;
            if (utils.haveToWindow() && window.CustomEvent) {
                var event_2 = new window.CustomEvent("custom-down-touchend", {
                    detail: detail
                });
                (_a = view.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(event_2);
            }
        }, []);
        var handleDownMove = React.useCallback(function (e) {
            var custom = e.type.indexOf('custom-') > -1; // 自定义事件
            var event = utils.getClientPos(custom ? e.detail : e);
            downMoveData.current.curve = { x: event.clientX, y: event.clientY }; // 当前点的位置
            var _a = getDownParams.current(), downOffset = _a.downOffset, downOutOffsetRate = _a.downOutOffsetRate;
            var downStatus = getDownState.current().downStatus;
            var upStatus = getUpState.current().upStatus;
            if (childrenNotAllowDown.current === false) {
                downTouchmoveCount.current += 1; // 滑动次数+1
                if (downTouchmoveCount.current === 1) {
                    var angle = utils.inclinedAngle(downMoveData.current.start, downMoveData.current.curve);
                    if (!((angle > 45 && angle < 135) || (angle > 225 && angle < 315))) { // 0 - 360
                        downAllow.current = false; // 不符合角度将不允许下拉
                    }
                }
                if (view.current // 有最外层的视图容器
                    && upStatus !== 1 // 不在上拉加载状态
                    && downAllow.current // 允许执行刷新
                    && [0, 1, 2, 3, 6].indexOf(downStatus) > -1 // 这些状态允许进入
                ) {
                    if ([3, 6].indexOf(downStatus) > -1) { // 在回弹的过程中 并且开启了回弹定时器
                        downClearTimer.current();
                    }
                    var scrollTop = view.current.scrollTop; // 视图容器内滚动高度
                    var changeHeight = downMoveData.current.curve.y - downMoveData.current.prev.y; //  改变的高度
                    if ((scrollTop <= 0 && changeHeight >= 0) // 在起始位置往下滑
                        || ([1, 2].indexOf(downStatus) > -1 && changeHeight < 0) // 在下拉的时候再往回推
                    ) {
                        utils.preventDefault(custom ? e.detail : e); // 许多浏览器有自己的下拉默认事件 需要阻止
                        if (changeHeight < 0) { // 往回推
                            if (downHeight.current < 1) { // 回推到不足1时 直接置为0 避免bug
                                downHeight.current = 0;
                            }
                            else {
                                downHeight.current += changeHeight; // 计算盒子的高度
                            }
                        }
                        else { // 下拉
                            if (downHeight.current >= downOffset) { // 临界值的判断 设置摩擦阻力
                                changeHeight *= downOutOffsetRate;
                            }
                            downHeight.current += changeHeight;
                        }
                        if (downRef.current) { // 设置down框的高度 以显示出来
                            downRef.current.setHeight(downHeight.current); // 调用函数设置高度
                        }
                        if (downHeight.current >= downOffset) { // 临界值的判断 判断计算好后的值符合何种状态
                            setDownStatus(2); // 置为下拉可刷新的状态
                        }
                        else {
                            setDownStatus(1); // 置为下拉不可刷新的状态
                        }
                    }
                }
            }
            downMoveData.current.prev = downMoveData.current.curve; // 结束后更新位置
        }, []);
        var handleDownEnd = React.useCallback(function (e) {
            var custom = e.type.indexOf('custom-') > -1; // 自定义事件
            if (utils.getBrowserVersion() === 'IE') {
                document.body.classList.remove('easy-prohibit-to-choose');
            }
            var downStatus = getDownState.current().downStatus;
            if (downStatus === 1 || (downStatus === 6 && !downTimer.current)) {
                // 未达到刷新条件 && 回弹的时候如果被打断 并且没有改变成其它状态的情况下 需要重启回弹
                toInitial.current();
            }
            else if (downStatus === 2 || (downStatus === 3 && !downTimer.current)) {
                // 达到刷新条件 && 回弹的时候如果被打断 并且没有改变成其它状态的情况下 需要重启回弹
                toRefresh.current();
            }
            if (utils.haveToWindow()) {
                window.removeEventListener('mousemove', handleDownMove);
                window.removeEventListener('mouseup', handleDownEnd);
                if (custom) { // 自定义事件需要解除
                    e.detail.target.removeEventListener('touchmove', customDownMove);
                    e.detail.target.removeEventListener('touchend', customDownStop);
                    e.detail.target.removeEventListener('touchcancel', customDownStop);
                    downEventTarget.current = null;
                }
            }
        }, [customDownMove, customDownStop, handleDownMove]);
        var handleDownStart = React.useCallback(function (e) {
            if (utils.getBrowserVersion() === 'IE') {
                document.body.classList.add('easy-prohibit-to-choose'); // 阻止默认事件会导致无法默认滚动 因此使用本方法禁止选中文字
            }
            var event = utils.getClientPos(e);
            downMoveData.current.start = { x: event.clientX, y: event.clientY }; // 记录手指起始位置
            downMoveData.current.prev = { x: event.clientX, y: event.clientY }; // 记录手指上一次位置
            if (childrenNotAllowDown.current === false) {
                downAllow.current = true;
                downTouchmoveCount.current = 0; // 滑动次数重新计算
                if (utils.haveToWindow()) {
                    window.removeEventListener('mousemove', handleDownMove);
                    window.removeEventListener('mouseup', handleDownEnd);
                    window.addEventListener('mousemove', handleDownMove);
                    window.addEventListener('mouseup', handleDownEnd);
                    if (e.target) {
                        if (downEventTarget.current && downEventTarget.current !== e.target) { // 后面的手指按下 并且按在不同的元素上 把上一个手指的事件删除
                            downEventTarget.current.removeEventListener('touchmove', customDownMove);
                            downEventTarget.current.removeEventListener('touchend', customDownStop);
                            downEventTarget.current.removeEventListener('touchcancel', customDownStop);
                        }
                        if (!downEventTarget.current || downEventTarget.current !== e.target) { // 第一指 或者后续按在其它元素上 重新绑定
                            e.target.addEventListener('touchmove', customDownMove, eventOptions);
                            e.target.addEventListener('touchend', customDownStop);
                            e.target.addEventListener('touchcancel', customDownStop);
                        }
                        downEventTarget.current = e.target;
                    }
                }
            }
        }, [customDownMove, customDownStop, eventOptions, handleDownEnd, handleDownMove]);
        // 事件绑定/解绑处理
        // 绑定流程
        // 1. true -> false 不在下拉状态 直接解绑
        // 2. true -> false 在下拉状态 延迟解绑
        // 3. false -> true 已解绑|未绑定 直接绑定
        // 4. false -> true 在延迟解绑状态 取消延迟解绑
        var downEventIsBind = React.useRef(false); // 当前是否绑定
        var downEventDelayDestroy = React.useRef(false); // 绑定需要延迟解绑
        var downEventBind = React.useCallback(function () {
            if (!downEventIsBind.current && view.current) { // 已解绑|未绑定 直接绑定
                downEventIsBind.current = true;
                view.current.addEventListener('mousedown', handleDownStart);
                view.current.addEventListener('touchstart', handleDownStart, eventOptions);
                view.current.addEventListener('custom-down-touchmove', handleDownMove);
                view.current.addEventListener('custom-down-touchend', handleDownEnd);
            }
            else if (downEventDelayDestroy.current) { // 在延迟解绑状态 取消延迟解绑
                downEventDelayDestroy.current = false;
            }
        }, [eventOptions, handleDownEnd, handleDownMove, handleDownStart]);
        var downEventDestroy = React.useCallback(function () {
            var downStatus = getDownState.current().downStatus;
            if (downEventIsBind.current && view.current) {
                if (downStatus === 0) { // 不在下拉状态 直接解绑
                    downEventIsBind.current = false;
                    downEventDelayDestroy.current = false; // 已经解绑 需要重置值
                    view.current.removeEventListener('mousedown', handleDownStart);
                    view.current.removeEventListener('touchstart', handleDownStart);
                    view.current.removeEventListener('custom-down-touchmove', handleDownMove);
                    view.current.removeEventListener('custom-down-touchend', handleDownEnd);
                }
                else if (downEventDelayDestroy.current === false) { //  在下拉状态 延迟解绑
                    downEventDelayDestroy.current = true;
                }
            }
        }, [handleDownEnd, handleDownMove, handleDownStart]);
        // 处理绑定与取消
        React.useEffect(function () {
            if (downEnable) { // 需要绑定
                downEventBind();
            }
            return downEventDestroy;
        }, [downEnable, downEventBind, downEventDestroy]);
        // 下拉刷新是一个持续的过程 在这个过程中如果禁用需要延迟执行
        React.useEffect(function () {
            if (downEnable === false && downStatus === 0 && downEventDelayDestroy.current) {
                downEventDestroy();
            }
        }, [downEnable, downEventDestroy, downStatus]);
        // 上拉加载逻辑
        var _l = up.enable, upEnable = _l === void 0 ? true : _l, _m = up.offset, upOffset = _m === void 0 ? 100 : _m, _o = up.renderDom, upRenderDom = _o === void 0 ? true : _o, _p = up.successStay, upSuccessStay = _p === void 0 ? 600 : _p, upLoading = up.loading, UpCustom = up.custom;
        var upParams = useParamFnFreeze({
            upEnable: upEnable,
            upOffset: upOffset,
            upRenderDom: upRenderDom,
            upSuccessStay: upSuccessStay,
            upLoading: upLoading
        });
        var getUpParams = React.useRef(function () { return upParams.current; }); // 为了在副作用函数上少写依赖
        var upSuccessTimer = React.useRef(); // 上拉加载成功定时器
        var upScrollMoveData = React.useRef({ prev: 0, curve: 0 }); // 滚动条位置信息 适用于scroll事件
        var upMoveData = React.useRef({
            start: { x: 0, y: 0 },
            prev: { x: 0, y: 0 },
            curve: { x: 0, y: 0 }
        });
        var upEventTarget = React.useRef(null); // 已绑定事件的对象 用于后面的手指按下时解绑前面的手指
        var loadComplete = React.useCallback(function (_a) {
            var success = _a.success, end = _a.end;
            var upSuccessStay = getUpParams.current().upSuccessStay;
            if (end) {
                setUpStatus(4); // 到底了
            }
            else {
                if (success) {
                    setUpStatus(2); // 获取成功
                    if (upSuccessStay > 0) { // 上拉加载只有成功才会短暂驻留
                        upSuccessTimer.current = setTimeout(function () {
                            setUpStatus(0);
                        }, upSuccessStay);
                    }
                    else {
                        setUpStatus(0);
                    }
                }
                else {
                    setUpStatus(3); // 获取失败
                }
            }
        }, []);
        // 事件
        var handleUpScroll = React.useCallback(function () {
            var downStatus = getDownState.current().downStatus;
            var _a = getUpParams.current(), upOffset = _a.upOffset, upLoading = _a.upLoading;
            var upStatus = getUpState.current().upStatus;
            if (view.current) {
                upScrollMoveData.current.curve = view.current.scrollTop; // 当前滚动位置
                var _b = upScrollMoveData.current, prev = _b.prev, curve = _b.curve;
                if (downStatus === 0 // 不在下拉中
                    && [0, 2, 3].indexOf(upStatus) > -1 // 无状态 加载成功 加载失败
                    && curve > prev // 向下滚动可加载
                ) {
                    var showHeight = curve + view.current.clientHeight; // 卷去的高度 + 盒子高度
                    var remain = view.current.scrollHeight - showHeight; // 距离底部的距离
                    if (remain < upOffset) { // 到达了临界点 触发加载
                        if (upStatus === 2) { // 如果是成功状态 需要清除一下定时器 因为可能正在提示成功中
                            clearTimeout(Number(upSuccessTimer.current));
                        }
                        setUpStatus(1);
                        if (upLoading) {
                            upLoading();
                        }
                    }
                }
                upScrollMoveData.current.prev = curve; // 当前滚动位置
            }
        }, []);
        var customUpMove = React.useCallback(function (detail) {
            var _a;
            if (utils.haveToWindow() && window.CustomEvent) {
                var event_3 = new window.CustomEvent("custom-up-touchmove", {
                    detail: detail
                });
                (_a = view.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(event_3);
            }
        }, []);
        var customUpStop = React.useCallback(function (detail) {
            var _a;
            if (utils.haveToWindow() && window.CustomEvent) {
                var event_4 = new window.CustomEvent("custom-up-touchend", {
                    detail: detail
                });
                (_a = view.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(event_4);
            }
        }, []);
        var handleUpMove = React.useCallback(function (e) {
            var custom = e.type.indexOf('custom-') > -1; // 自定义事件 
            var event = utils.getClientPos(custom ? e.detail : e);
            var downStatus = getDownState.current().downStatus;
            var upLoading = getUpParams.current().upLoading;
            var upStatus = getUpState.current().upStatus;
            upMoveData.current.curve = { x: event.clientX, y: event.clientY }; // 当前点的位置
            if (childrenNotAllowDown.current === false) {
                if (view.current
                    && downStatus === 0 // 不在下拉中
                    && [0, 2, 3].indexOf(upStatus) > -1 // 无状态 加载成功 加载失败
                    && upMoveData.current.curve.y < upMoveData.current.prev.y // 向上拉
                ) {
                    var remain = view.current.scrollHeight - (view.current.scrollTop + view.current.clientHeight); // 距离底部的距离
                    if (remain === 0) { // 触底了 触发加载 解决触底时继续上拉无法触发scroll事件的问题
                        var angle = utils.inclinedAngle(upMoveData.current.start, upMoveData.current.curve);
                        if (angle > 225 && angle < 315) { // 此处与下拉刷新不同 始终以当前点与最初点形成夹角
                            if (upStatus === 2) { // 如果是成功状态 需要清除一下定时器 因为可能正在提示成功中
                                clearTimeout(Number(upSuccessTimer.current));
                            }
                            setUpStatus(1);
                            if (upLoading) {
                                upLoading();
                            }
                        }
                    }
                }
            }
            upMoveData.current.prev = upMoveData.current.curve; // 结束后更新位置
        }, []);
        var handleUpEnd = React.useCallback(function (e) {
            var custom = e.type.indexOf('custom-') > -1; // 自定义事件
            if (utils.haveToWindow()) {
                window.removeEventListener('mousemove', handleUpMove);
                window.removeEventListener('mouseup', handleUpEnd);
                if (custom) { // 自定义事件需要解除
                    e.detail.target.removeEventListener('touchmove', customUpMove);
                    e.detail.target.removeEventListener('touchend', customUpStop);
                    e.detail.target.removeEventListener('touchcancel', customUpStop);
                    upEventTarget.current = null;
                }
            }
        }, [customUpMove, customUpStop, handleUpMove]);
        var handleUpStart = React.useCallback(function (e) {
            var event = utils.getClientPos(e);
            upMoveData.current.start = { x: event.clientX, y: event.clientY }; // 记录手指起始位置
            upMoveData.current.prev = { x: event.clientX, y: event.clientY }; // 记录手指上一次位置
            if (childrenNotAllowDown.current === false && view.current) {
                var _a = view.current, scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
                upScrollMoveData.current.curve = scrollTop; // 当前滚动位置
                upScrollMoveData.current.prev = scrollTop; // 当前滚动位置
                var remain = scrollHeight - scrollTop - clientHeight; // 距离底部的距离
                if (remain === 0) { // 触底了 绑定滑动事件 解决触底时继续上拉无法触发scroll事件的问题
                    if (utils.haveToWindow()) {
                        window.removeEventListener('mousemove', handleUpMove);
                        window.removeEventListener('mouseup', handleUpEnd);
                        window.addEventListener('mousemove', handleUpMove);
                        window.addEventListener('mouseup', handleUpEnd);
                        if (e.target) {
                            if (upEventTarget.current && upEventTarget.current !== e.target) { // 后面的手指按下 并且按在不同的元素上 把上一个手指的事件删除
                                upEventTarget.current.removeEventListener('touchmove', customUpMove);
                                upEventTarget.current.removeEventListener('touchend', customUpStop);
                                upEventTarget.current.removeEventListener('touchcancel', customUpStop);
                            }
                            if (!upEventTarget.current || upEventTarget.current !== e.target) { // 第一指 或者后续按在其它元素上 重新绑定
                                e.target.addEventListener('touchmove', customUpMove, eventOptions);
                                e.target.addEventListener('touchend', customUpStop);
                                e.target.addEventListener('touchcancel', customUpStop);
                            }
                            upEventTarget.current = e.target;
                        }
                    }
                }
            }
        }, [customUpMove, customUpStop, eventOptions, handleUpEnd, handleUpMove]);
        // 事件绑定/解绑处理
        var upEventIsBind = React.useRef(false); // 当前是否绑定
        // 绑定
        var upEventBind = React.useCallback(function () {
            if (!upEventIsBind.current && view.current) { // 当前未绑定
                upEventIsBind.current = true;
                view.current.addEventListener('scroll', handleUpScroll);
                view.current.addEventListener('mousedown', handleUpStart);
                view.current.addEventListener('touchstart', handleUpStart, eventOptions);
                view.current.addEventListener('custom-up-touchmove', handleUpMove);
                view.current.addEventListener('custom-up-touchend', handleUpEnd);
            }
        }, [eventOptions, handleUpEnd, handleUpMove, handleUpScroll, handleUpStart]);
        // 解绑
        var upEventDestroy = React.useCallback(function () {
            if (upEventIsBind.current && view.current) { // 当前已绑定
                upEventIsBind.current = false;
                view.current.removeEventListener('scroll', handleUpScroll);
                view.current.removeEventListener('mousedown', handleUpStart);
                view.current.removeEventListener('touchstart', handleUpStart);
                view.current.removeEventListener('custom-up-touchmove', handleUpMove);
                view.current.removeEventListener('custom-up-touchend', handleUpMove);
            }
        }, [handleUpMove, handleUpScroll, handleUpStart]);
        React.useEffect(function () {
            if (upEnable) { // 需要绑定
                upEventBind();
            }
            return upEventDestroy;
        }, [upEnable, upEventBind, upEventDestroy]);
        // 懒加载 
        var _q = lazy.enable, lazyEnable = _q === void 0 ? true : _q, _r = lazy.offset, lazyOffset = _r === void 0 ? 100 : _r, _s = lazy.srcAttribute, lazySrcAttribute = _s === void 0 ? 'data-lazy' : _s;
        var lazyParams = useParamFnFreeze({
            lazyEnable: lazyEnable,
            lazyOffset: lazyOffset,
            lazySrcAttribute: lazySrcAttribute,
        });
        var getLazyParams = React.useRef(function () { return lazyParams.current; }); // 为了在副作用函数上少写依赖
        var lazyEventIsBind = React.useRef(false); // 是否绑定了事件
        var handleLazyScroll = React.useCallback(function () {
            if (view.current) {
                // 显示图片的高度
                var _a = getLazyParams.current(), lazySrcAttribute_1 = _a.lazySrcAttribute, lazyOffset_1 = _a.lazyOffset;
                var showHeight = view.current.clientHeight + lazyOffset_1; // 图片距离屏幕顶部的距离小于这个数 就需要显示
                var lazyImg = document.querySelectorAll("img[" + lazySrcAttribute_1 + "]"); // 所有使用了懒加载的IMG标签
                for (var i = 0; i < lazyImg.length; i += 1) {
                    var img = lazyImg[i];
                    if (img.getBoundingClientRect().top <= showHeight) {
                        img.setAttribute('src', img.getAttribute(lazySrcAttribute_1) || '');
                        img.removeAttribute(lazySrcAttribute_1);
                    }
                }
            }
        }, []);
        var lazyEventBind = React.useCallback(function () {
            if (!lazyEventIsBind.current && view.current) {
                lazyEventIsBind.current = true;
                view.current.addEventListener('scroll', handleLazyScroll);
            }
        }, [handleLazyScroll]);
        var lazyEventDestroy = React.useCallback(function () {
            if (lazyEventIsBind.current && view.current) {
                lazyEventIsBind.current = false;
                view.current.removeEventListener('scroll', handleLazyScroll);
            }
        }, [handleLazyScroll]);
        React.useEffect(function () {
            if (lazyEnable) {
                handleLazyScroll();
                lazyEventBind();
            }
            return lazyEventDestroy;
        }, [lazyEnable, handleLazyScroll, lazyEventBind, lazyEventDestroy]);
        // 暴露的事件
        React.useImperativeHandle(ref, function () { return ({
            downComplete: downComplete,
            loadComplete: loadComplete
        }); });
        // 下拉节点的参数
        var downProps = React.useMemo(function () { return ({
            ref: downRef,
            status: downStatus,
            offset: downOffset,
            outOffsetRate: downOutOffsetRate
        }); }, [downOffset, downOutOffsetRate, downStatus]);
        var DownMemo = React.useMemo(function () {
            return React.forwardRef(DownCustom ? DownCustom : Down);
        }, [DownCustom]);
        // 上拉节点参数
        var upProps = React.useMemo(function () { return ({
            status: upStatus
        }); }, [upStatus]);
        var UpMemo = React.useMemo(function () {
            return UpCustom ? UpCustom : Up;
        }, [UpCustom]);
        // 必须写在最后，将初次进入的标识置为否
        React.useEffect(function () {
            firstEntry.current = false;
        }, []);
        return (React__default['default'].createElement("div", { className: "easy-scroll-view", ref: view },
            React__default['default'].createElement(DownMemo, __assign({}, downProps)),
            React__default['default'].createElement("div", { className: "easy-scroll-body" }, children),
            side.button ? React__default['default'].createElement(Side, __assign({}, side, { childrenNotAllowDown: childrenNotAllowDown })) : null,
            upEnable && upRenderDom ? React__default['default'].createElement(UpMemo, __assign({}, upProps)) : null));
    }
    var Scroll = React.forwardRef(ScrollView);

    function getData10() {
        var count = 1;
        function create() {
            var data = [];
            for (var i = count; i <= count + 9; i += 1) {
                data.push({
                    id: i.toString(),
                    text: i.toString()
                });
            }
            count += 10;
            return data;
        }
        function reset() {
            count = 1;
            return create();
        }
        return {
            reset: reset,
            create: create
        };
    }

    function Item(props) {
        var data = props.data;
        var content = React.useRef(null);
        var action = React.useRef(null);
        // const init = useRef({ content: 0, action: 0, initial: false });
        var handleSwipeLeft = React.useCallback(function () {
            // e, distance
            // console.log('左滑', distance)
            // if (content.current && action.current) {
            //   if (init.current.initial === false) {
            //     init.current.initial = true;
            //     init.current.content = parseFloat(window.getComputedStyle(content.current).left);
            //     init.current.action = parseFloat(window.getComputedStyle(action.current).right);
            //   }
            //   content.current.style.left = `${init.current.content - distance}px`;
            //   action.current.style.right = `${init.current.action + distance}px`;
            // }
        }, []);
        if (data) {
            return (React__default['default'].createElement(lib
            // preventDefault
            , { 
                // preventDefault
                onSwipeLeft: handleSwipeLeft },
                React__default['default'].createElement("li", null,
                    React__default['default'].createElement("div", { ref: content, className: "content" }, data.text),
                    React__default['default'].createElement("div", { ref: action, className: "action" }, "\u5220\u9664"))));
        }
        return React__default['default'].createElement(React__default['default'].Fragment, null);
    }

    function App() {
        useIOSActive(); // 激活ios active事件
        var scrollViewRef = React.useRef();
        var getData = React.useMemo(function () { return getData10(); }, []);
        var _a = React.useState(getData.create()), data = _a[0], setData = _a[1];
        /**
         * 下拉刷新
         */
        var refreshCount = React.useRef(0);
        var refreshing = React.useCallback(function () {
            refreshCount.current += 1;
            setTimeout(function () {
                if (scrollViewRef.current) {
                    if (refreshCount.current % 3 !== 0) { // 成功时刷新数据
                        setData(getData.create());
                    }
                    scrollViewRef.current.downComplete({
                        // 不论成功或者失败 都需要调用刷新完成函数 否则将停滞在刷新中
                        success: refreshCount.current % 3 !== 0 // 参数为是否成功 success boolean
                    });
                }
            }, 1000);
        }, [getData]);
        /**
         * 上拉加载
         */
        var loadCount = React.useRef(0);
        var loading = React.useCallback(function () {
            loadCount.current += 1;
            setTimeout(function () {
                if (scrollViewRef.current) {
                    if (loadCount.current !== 3) {
                        setData(function (prevState) { return (__spreadArray(__spreadArray([], prevState), getData.create())); });
                    }
                    scrollViewRef.current.loadComplete({
                        // 需要调用加载完成函数 否则将停滞在加载中
                        success: loadCount.current !== 3,
                        end: loadCount.current === 5 // 参数为是否到底了 end boolean
                    });
                }
            }, 2000);
        }, [getData]);
        return (React__default['default'].createElement(Scroll, { ref: scrollViewRef, down: { refreshing: refreshing }, up: { loading: loading }, side: {
                button: [
                    {
                        children: '说明',
                        onTap: function () {
                            // explain();
                            alert('11');
                        }
                    },
                    { inlayType: 'theTop' }
                ]
            } },
            React__default['default'].createElement("ul", { className: "scroll-view-list", style: { fontSize: 24 } }, data.map(function (item) { return React__default['default'].createElement(Item, { key: item.id, data: item }); })),
            React__default['default'].createElement("div", null,
                React__default['default'].createElement("img", { style: { display: 'block', width: '100%', marginTop: 10 }, "data-lazy": "https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=240310730,3135775327&fm=26&gp=0.jpg", alt: "" }))));
    }

    // 最大的倍数
    function maxFontSize() {
        var clientWidth = document.body.clientWidth;
        if (clientWidth > 500) {
            document.documentElement.style.fontSize = '50px';
        }
        else {
            document.documentElement.style.fontSize = clientWidth / 10 + "px";
        }
    }
    maxFontSize();
    window.addEventListener('resize', maxFontSize);
    ReactDOM__default['default'].render(React__default['default'].createElement(App, null), document.querySelector('#app'));

})));
